<template>
  <nav class="navbar navbar-dark bg-dark" v-if="user">
<router-link class="navbar-brand" to='/'>HOME</router-link>
<div class="list-inline-item" v-if="!user.isLogin">
    <router-link to="/login" class="list-inline-item text-white btn my-2 btn-outline-light">登录</router-link>
    <router-link to="/login" class="list-inline-item text-white btn my-2 btn-outline-light">注册</router-link>
</div>
<div v-else>
    <Dropdown :title="`你好${user.nickName}`">
      <DropdownItem :disabled='false'><router-link class="dropdown-item text-justify" to="/Create">新建文章</router-link></DropdownItem>
      <DropdownItem><a class="dropdown-item" href="#">删除文章</a></DropdownItem>
      <DropdownItem><a class="dropdown-item" href="#">退出登录</a></DropdownItem>
    </Dropdown>
</div>
</nav>

</template>

<script lang='ts'>
import { defineComponent, PropType } from 'vue'
import Dropdown from './Dropdown.vue'
import DropdownItem from './DropdownItem.vue'
import { UserProps } from '../store'

export default defineComponent({
  name: 'GlobalHeader',
  components: {
    Dropdown,
    DropdownItem
  },
  props: {
    user: {
      type: Object as PropType <UserProps>,
      require: true
    }
  }

})
</script>

<style>
.navbar{
  margin-top: -60px;
}
</style>
